// pref.h: interface for the CLPref class.
// $Id: pref.h,v 1.4 2008/04/17 04:00:27 leon Exp $
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PREF_H__5930E2CC_603B_4736_B2C6_3414E8396752__INCLUDED_)
#define AFX_PREF_H__5930E2CC_603B_4736_B2C6_3414E8396752__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "str.h"
#ifdef _WIN32
#include "win32/gdbm.h"
#else
#include <gdbm.h>
#endif

class CLPref  
{
public:
	int keys(CLStrList& keylist);
	CLPref():m_dbf(0){};
	CLPref(CLStr filename,int mode=CLPref::reader):m_dbf(0) { open(filename,mode); };
	~CLPref() { close(); };

	void open(CLStr filename,int mode=CLPref::reader);
	CLStr get(CLStr key,CLStr def="");
	int set(CLStr key,CLStr val);
	void close();
	int backup(LPCSTR filename);
	int restore(LPCSTR filename);

	static const int reader;
	static const int wrcreat;
private:
	GDBM_FILE m_dbf;
};

#endif // !defined(AFX_PREF_H__5930E2CC_603B_4736_B2C6_3414E8396752__INCLUDED_)
